

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改专家信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <input type="hidden" name="expertId" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-item">
        <input type="hidden" name="expertPassword" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="expertName" lay-verify="required" placeholder="请输入专家姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="text" name="expertPhone" lay-verify="required" placeholder="请输入专家手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline">
            <select name="expertSex" lay-verify="required">
                <option value="0">男</option>
                <option value="1">女</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="expertEmail"placeholder="请输入专家邮箱" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录账号</label>
        <div class="layui-input-inline">
            <input type="text" name="expertUsername" lay-verify="required" placeholder="请输入登录账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属角色</label>
        <div class="layui-input-inline">
            <select name="roleName" lay-verify="required">
                <option value="ADMIN" disabled>管理员</option>
                <option value="EXPERT" selected>专家</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
</div>

<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
            ,form = layui.form;

        //回显
        var editData = parent.editData;
        $('[name=expertId]').val(editData.expertId);
        $('[name=expertPassword]').val(editData.expertPassword);
        $('[name=expertName]').val(editData.expertName);
        $('[name=expertPhone]').val(editData.expertPhone);
        $('[name=expertEmail]').val(editData.expertEmail);
        $('[name=expertUsername]').val(editData.expertUsername);
        $('[name=expertSex] option').each(function () {
            if($(this).val() == editData.expertSex){
                $(this).attr("selected",true);
            }
        });
        form.render(); //重新渲染

        //监听提交
        form.on('submit(layuiadmin-app-form-submit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            $.ajax({
                url:"/admin/expert/expert",
                method:"put",
                data:field,
                dataType:"json",
                async:false,
                success:function(obj){
                    if(obj.code == 0){
                        parent.layui.table.reload('table-expert'); //重载表格
                        parent.layer.close(index); //再执行关闭
                    }else{
                        layer.msg(obj.msg, {
                            offset: '15px'
                            ,icon: 2
                            ,time:2000
                        });
                    }
                }
            });
        });
    })
</script>
</body>
</html>